package com.vlada.studzad.pages;

import java.util.List;

import org.apache.tapestry5.annotations.ApplicationState;
import org.apache.tapestry5.annotations.Property;
import org.apache.tapestry5.grid.GridDataSource;

import com.vlada.studzad.data.MockDataJobOfferSource;
import com.vlada.studzad.model.JobOffer;
import com.vlada.studzad.model.Privilege;
import com.vlada.studzad.model.User;
import com.vlada.studzad.util.JobOfferSource;

public class PreviewJobOffers {
	
	@ApplicationState
	@Property
	private User user;
	private boolean userExists;	
	
	Object onActivate() {
		if (!userExists)return Index.class;
		else if(user.getPrivilege()==Privilege.EMPLOYER){
			return null;
		}
		return Index.class;
	}
	
	@ApplicationState
	private MockDataJobOfferSource jobOffers;
	private JobOffer jobOffer;
	
	public List<JobOffer> getAllJobOffers() {
		return jobOffers.getAllJobOffers();
	}
	
	

	public GridDataSource getJobOfferSource() {
		return new JobOfferSource(jobOffers);
	}



	public void setJobOffer(JobOffer jobOffer) {
		this.jobOffer = jobOffer;
	}



	public JobOffer getJobOffer() {
		return jobOffer;
	}
	
}
